import { useState,lazy } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import '@/App.css'
import {Button,ConfigProvider} from "antd"
import type { AnyAction } from "@reduxjs/toolkit";
import renderRoutes from "@/router/index";
import { BrowserRouter,HashRouter, Routes, Route,createBrowserRouter,useRoutes,useNavigate } from "react-router-dom";
import { useSelector, useDispatch } from "react-redux" 
import routes from "@/router/index"

const Layout=import("@/layout/index")

const Home=lazy(()=>import("@/pages/home/index"))


// 引入index中的RootState类型  js项目不需要
import { AppDispatch, RootState } from "@/store" 
// 引入functions
import {updated,routerState } from "@/store/modules/router"
//实现路由拦截
const Authen = (props:{route:any,children:[]}) => {
  const navigate = useNavigate()
  const { route, children } = props
  const username = sessionStorage.getItem('username')
  
  const routerData1=route.props.match.route
  
  // 缓存路由信息用于顶部的面包屑导航
  const routerData = useSelector((state: RootState) => state.router)
  const dispatch: AppDispatch = useDispatch() // 异步函数必须加AppDispatch类型，否则报错，同步可以不添加
 
  
  
  
 
  return children
}

function App() {
  const element = useRoutes(routes)

  
  return (
    
    // </Routes>
  <div>
 
   {element}
      
  </div>
  )
}

export default App
